<?php
//Requires connectDB
require("dbFunctions.php");

//Mysql Parameters
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];

if( !isset($email) )
	die("Email not provided.");
if( !isset($password) || is_null($password) )
	die("Password not provided.");

//Get the hash of the password since that's what is stored in the database
$pw_hash = hash("sha256",$password);

$dbh = connectDB();

$query = "SELECT * FROM Suppliers WHERE email=:email AND admin_password=:admin_pass AND is_active=1";
$stmt = $dbh->prepare($query);
$stmt->bindParam(':email',$email);
$stmt->bindParam(':admin_pass',$pw_hash);
$stmt->execute();

if($stmt->rowCount() == 1)
	exit();
else
	die("Invalid email-password combination.");
?>
